From 07ad427400d01edd1023ce1e8ae4a52af823ed64 Mon Sep 17 00:00:00 2001 From: Uttkarsh Date: Wed, 26 Feb 2014 13:56:19 +0530 Subject: [PATCH] Simple make utility for user space --- usr_make/README | 4 ++++ usr_make/include/hellomake.h | 6 ++++++ usr_make/src/Makefile | 25 +++++++++++++++++++++++++ usr_make/src/hellofunc.c | 8 ++++++++ usr_make/src/hellomake.c | 8 ++++++++ 5 files changed, 51 insertions(+) create mode 100644 usr_make/README create mode 100644 usr_make/include/hellomake.h create mode 100644 usr_make/src/Makefile create mode 100644 usr_make/src/hellofunc.c create mode 100644 usr_make/src/hellomake.c diff --git a/usr_make/README b/usr_make/README new file mode 100644 index 0000000..a21e355 --- /dev/null +++ b/usr_make/README @@ -0,0 +1,4 @@ +No time for detailed explanation +Followed this tutorial +http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/ + diff --git a/usr_make/include/hellomake.h b/usr_make/include/hellomake.h new file mode 100644 index 0000000..7a74608 --- /dev/null +++ b/usr_make/include/hellomake.h @@ -0,0 +1,6 @@ +#ifndef HELLOMAKE_H +#define HELLOMAKE_H + +void myPrintHelloMake(void); + +#endif /*HELLOMAKE_H*/ diff --git a/usr_make/src/Makefile b/usr_make/src/Makefile new file mode 100644 index 0000000..dc5c125 --- /dev/null +++ b/usr_make/src/Makefile @@ -0,0 +1,25 @@ +IDIR = ../include +CC=gcc +CFLAGS=-I$(IDIR) + +ODIR=obj +LDIR=../lib + +LIBS=-lm + +_DEPS = hellomake.h +DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS)) + +_OBJ = hellomake.o hellofunc.o +OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ)) + +$(ODIR)/%.o: %.c $(DEPS) + $(CC) -c -o $@ $< $(CFLAGS) + +hellomake: hellomake.o hellofunc.o + gcc -o $@ $^ $(CFLAGS) $(LIBS) + +.PHONY: clean + +clean: + rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~ diff --git a/usr_make/src/hellofunc.c b/usr_make/src/hellofunc.c new file mode 100644 index 0000000..fb5c566 --- /dev/null +++ b/usr_make/src/hellofunc.c @@ -0,0 +1,8 @@ +#include + +void myPrintHelloMake(void) { + + printf("Hello makefiles!\n"); + + return; +} diff --git a/usr_make/src/hellomake.c b/usr_make/src/hellomake.c new file mode 100644 index 0000000..3d673b7 --- /dev/null +++ b/usr_make/src/hellomake.c @@ -0,0 +1,8 @@ +#include + +int main() { + // call a function in another file + myPrintHelloMake(); + + return(0); +}