From ddfc7cad49c8704240a0d36d2ff1f400beff1699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 23 Apr 2012 10:00:14 +0200 Subject: add makefile-djb --- makefile-djb/AUTHOR | 0 makefile-djb/Changelog | 0 makefile-djb/LICENSE | 0 makefile-djb/Makefile | 26 +++++++++++ makefile-djb/Makefile_base | 113 +++++++++++++++++++++++++++++++++++++++++++++ makefile-djb/README | 0 makefile-djb/clib.c | 8 ++++ makefile-djb/clib.h | 9 ++++ makefile-djb/conf-arch | 1 + makefile-djb/conf-cc | 3 ++ makefile-djb/conf-ld | 3 ++ makefile-djb/main.c | 9 ++++ makefile-djb/test | 4 ++ makefile-djb/warn-auto.sh | 2 + 14 files changed, 178 insertions(+) create mode 100644 makefile-djb/AUTHOR create mode 100644 makefile-djb/Changelog create mode 100644 makefile-djb/LICENSE create mode 100644 makefile-djb/Makefile create mode 100644 makefile-djb/Makefile_base create mode 100644 makefile-djb/README create mode 100644 makefile-djb/clib.c create mode 100644 makefile-djb/clib.h create mode 100644 makefile-djb/conf-arch create mode 100644 makefile-djb/conf-cc create mode 100644 makefile-djb/conf-ld create mode 100644 makefile-djb/main.c create mode 100755 makefile-djb/test create mode 100644 makefile-djb/warn-auto.sh diff --git a/makefile-djb/AUTHOR b/makefile-djb/AUTHOR new file mode 100644 index 0000000..e69de29 diff --git a/makefile-djb/Changelog b/makefile-djb/Changelog new file mode 100644 index 0000000..e69de29 diff --git a/makefile-djb/LICENSE b/makefile-djb/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/makefile-djb/Makefile b/makefile-djb/Makefile new file mode 100644 index 0000000..12bf960 --- /dev/null +++ b/makefile-djb/Makefile @@ -0,0 +1,26 @@ +DIR=. + +include Makefile_base + +clib.o: compile clib.h clib.c + @./compile clib.c + +libclib.a: load clib.o + @./load s libclib.a clib.o + +main.o: compile clib.h main.c + @./compile main.c + +main: load libclib.a main.o + @./load c main libclib.a + +# HIGH LEVEL SPECIFIC TARGETS + +clean : cleanstd + @rm -f main *.o *.so* *~ + +arch: buildarch + -@./buildarch test + +build: main + diff --git a/makefile-djb/Makefile_base b/makefile-djb/Makefile_base new file mode 100644 index 0000000..ca1a94c --- /dev/null +++ b/makefile-djb/Makefile_base @@ -0,0 +1,113 @@ + +# Don't edit this Makefile! Use conf-* for configuration. + +###################################### + +SHELL=/bin/sh + +CYAN=\033[3;36m +RED=\033[3;31m +NORM=\033[0m + +default: build + +# GENERATE : buildarch - choose - compile - load - testflag + +buildarch : ${DIR}/warn-auto.sh conf-arch LICENSE README AUTHOR Changelog + @echo -e "$(CYAN)generating buildarch$(NORM)" + @( cat ${DIR}/warn-auto.sh; \ + echo "ARCH=`head -1 conf-arch`"; \ + echo 'echo -e "building $(RED)$${ARCH}$(NORM)"'; \ + echo 'P=`pwd` && P=$${P##*/};'; \ + echo 'FILES="$${P}/Makefile* $${P}/warn-auto.sh $${P}/LICENSE $${P}/README $${P}/AUTHOR $${P}/Changelog \ + $${P}/conf-* $${P}/*.h* $${P}/*.c*";'; \ + echo 'for I in $$@; do FILES="$${FILES} $${P}/$$I "; done;'; \ + echo 'cd .. && tar --exclude=*~ -chzf $${P}/$${ARCH} $${FILES} ' \ + ) > buildarch + @chmod 755 buildarch + +choose : ${DIR}/warn-auto.sh + @echo -e "$(CYAN)generating choose$(NORM)" + @( cat ${DIR}/warn-auto.sh; \ + echo 'result="$$3"'; \ + echo 'case "$$1" in'; \ + echo ' *c*) ./compile $$2.c >/dev/null 2>&1 || result="$$4" ;;'; \ + echo 'esac'; \ + echo 'case "$$1" in'; \ + echo ' *l*) ./load c $$2 >/dev/null 2>&1 || result="$$4" ;;'; \ + echo 'esac'; \ + echo 'case "$$1" in'; \ + echo ' *r*) ./$$2 >/dev/null 2>&1 || result="$$4" ;;'; \ + echo 'esac'; \ + echo 'rm -f $$2.o $$2'; \ + echo 'cat $$result'; \ + ) > choose + @chmod 755 choose + +compile : ${DIR}/warn-auto.sh conf-cc + @echo -e "$(CYAN)generating compile$(NORM)" + @( cat ${DIR}/warn-auto.sh; \ + echo 'echo -e "`head -1 conf-cc` -c $(RED)$${1} $(NORM)"'; \ + echo '`head -1 conf-cc` -c "$$1"'; \ + ) > compile + @chmod 755 compile + +load : ${DIR}/warn-auto.sh conf-ld + @echo -e "$(CYAN)generating load$(NORM)" + @( cat ${DIR}/warn-auto.sh; \ + echo 'choice=$$1; shift;'; \ + echo 'name=$$1; shift;'; \ + echo 'case "$$choice" in'; \ + echo ' *c*)'; \ + echo ' echo -e "`head -1 conf-ld` -o $(RED)$${name} $${name}.o $${1+"$$@"} $(NORM)"'; \ + echo ' `head -1 conf-ld` -o "$$name" "$$name".o $${1+"$$@"}'; \ + echo ' ;;'; \ + echo ' *d*)'; \ + echo ' echo -e "`head -1 conf-ld` $$name -o $(RED)$${name} $${1+"$$@"} $(NORM)"'; \ + echo ' `head -1 conf-ld` -o "$$name" $${1+"$$@"}'; \ + echo ' ;;'; \ + echo ' *s*)'; \ + echo ' echo -e "ar -cr $(RED)$${name} $${1+"$$@"} $(NORM)"'; \ + echo ' rm -f "$$name"; ar -cr "$$name" $${1+"$$@"}; ranlib "$$name"'; \ + echo ' ;;'; \ + echo 'esac'; \ + ) > load + @chmod 755 load + +testflag : ${DIR}/warn-auto.sh + @echo -e "$(CYAN)generating testflag$(NORM)" + @( cat ${DIR}/warn-auto.sh; \ + echo 'FLAG="$$1"; shift'; \ + echo 'for I in "$$@"; do echo "#include \"$$I\""; done;'; \ + echo 'echo "int main() {"'; \ + echo 'echo "#ifdef "$$FLAG"" '; \ + echo 'echo " return 0;"'; \ + echo 'echo "#else"'; \ + echo 'echo " return 1;"'; \ + echo 'echo "#endif"'; \ + echo 'echo }'; \ + ) > testflag + @chmod 755 testflag + +# HIGH LEVEL GENERAL TARGETS +buildstd : + @echo -e "$(CYAN)building `pwd`$(NORM)"; + @for I in ${SUBDIR}; do \ + ( echo -e "$(CYAN)building `pwd`/$$I$(NORM)" && cd $$I && make -s ); \ + done; + +cleanstd : + @echo -e "$(CYAN)cleaning `pwd`$(NORM)"; + @for I in ${SUBDIR}; do ( cd $$I && make -s clean ); done; + @if [ -f conf-arch ]; then if [ -f `head -1 conf-arch` ]; then rm `head -1 conf-arch`; fi; fi + @if [ -f buildarch ]; then rm buildarch; fi + @if [ -f choose ]; then rm choose; fi + @if [ -f compile ]; then rm compile; fi + @if [ -f load ]; then rm load; fi + @if [ -f testflag ]; then rm testflag; fi + @if [ "x`ls *~ 2>/dev/null`" != "x" ]; then rm *~; fi + @if [ "x`ls *.a 2>/dev/null`" != "x" ]; then rm *.a; fi + @if [ "x`ls *.o 2>/dev/null`" != "x" ]; then rm *.o; fi + @if [ "x`ls *.so* 2>/dev/null`" != "x" ]; then rm *.so*; fi + +# PACKAGE SPECIFIC TARGETS diff --git a/makefile-djb/README b/makefile-djb/README new file mode 100644 index 0000000..e69de29 diff --git a/makefile-djb/clib.c b/makefile-djb/clib.c new file mode 100644 index 0000000..73c1c03 --- /dev/null +++ b/makefile-djb/clib.c @@ -0,0 +1,8 @@ + +#include "clib.h" + +void say_hello(FILE *stream) +{ + fprintf(stream,"hello world\n"); +} + diff --git a/makefile-djb/clib.h b/makefile-djb/clib.h new file mode 100644 index 0000000..290c27a --- /dev/null +++ b/makefile-djb/clib.h @@ -0,0 +1,9 @@ + +#ifndef __C_LIB_H__ +#define __C_LIB_H__ + +#include + +void say_hello(FILE *stream); + +#endif /* __C_LIB_H__ */ diff --git a/makefile-djb/conf-arch b/makefile-djb/conf-arch new file mode 100644 index 0000000..fe09eac --- /dev/null +++ b/makefile-djb/conf-arch @@ -0,0 +1 @@ +clib.tar.gz diff --git a/makefile-djb/conf-cc b/makefile-djb/conf-cc new file mode 100644 index 0000000..b5c184b --- /dev/null +++ b/makefile-djb/conf-cc @@ -0,0 +1,3 @@ +gcc -O2 -Wall -pedantic + +This will be used to compile .c files. diff --git a/makefile-djb/conf-ld b/makefile-djb/conf-ld new file mode 100644 index 0000000..59a0de7 --- /dev/null +++ b/makefile-djb/conf-ld @@ -0,0 +1,3 @@ +gcc -s + +This will be used to link .o files into an executable. diff --git a/makefile-djb/main.c b/makefile-djb/main.c new file mode 100644 index 0000000..c0f51b7 --- /dev/null +++ b/makefile-djb/main.c @@ -0,0 +1,9 @@ +#include +#include "clib.h" + +int main(int argc, char* argv[], char* envp[]) +{ + say_hello(stdout); + return 0; +} + diff --git a/makefile-djb/test b/makefile-djb/test new file mode 100755 index 0000000..092aa7d --- /dev/null +++ b/makefile-djb/test @@ -0,0 +1,4 @@ +#!/bin/bash +DIR=$(dirname $0) +cd $DIR && make clean && make && ./main || exit 1 + diff --git a/makefile-djb/warn-auto.sh b/makefile-djb/warn-auto.sh new file mode 100644 index 0000000..36d2313 --- /dev/null +++ b/makefile-djb/warn-auto.sh @@ -0,0 +1,2 @@ +#!/bin/sh +# WARNING: This file was auto-generated. Do not edit! -- cgit v1.1-2-g2b99