summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-04-23 10:00:14 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2012-04-23 10:00:14 +0200
commitddfc7cad49c8704240a0d36d2ff1f400beff1699 (patch)
treeee06220f037fb42c2de1f5a0b9d34808b37e0024
parent48db83e5666b1bfd0c752f98f991dc83cb29dfb8 (diff)
downloadskeletons-ddfc7cad49c8704240a0d36d2ff1f400beff1699.zip
skeletons-ddfc7cad49c8704240a0d36d2ff1f400beff1699.tar.gz
add makefile-djb
-rw-r--r--makefile-djb/AUTHOR0
-rw-r--r--makefile-djb/Changelog0
-rw-r--r--makefile-djb/LICENSE0
-rw-r--r--makefile-djb/Makefile26
-rw-r--r--makefile-djb/Makefile_base113
-rw-r--r--makefile-djb/README0
-rw-r--r--makefile-djb/clib.c8
-rw-r--r--makefile-djb/clib.h9
-rw-r--r--makefile-djb/conf-arch1
-rw-r--r--makefile-djb/conf-cc3
-rw-r--r--makefile-djb/conf-ld3
-rw-r--r--makefile-djb/main.c9
-rwxr-xr-xmakefile-djb/test4
-rw-r--r--makefile-djb/warn-auto.sh2
14 files changed, 178 insertions, 0 deletions
diff --git a/makefile-djb/AUTHOR b/makefile-djb/AUTHOR
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/makefile-djb/AUTHOR
diff --git a/makefile-djb/Changelog b/makefile-djb/Changelog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/makefile-djb/Changelog
diff --git a/makefile-djb/LICENSE b/makefile-djb/LICENSE
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/makefile-djb/LICENSE
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
--- /dev/null
+++ b/makefile-djb/README
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 <stdio.h>
+
+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 <stdio.h>
+#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!