- src/ - hellofunc.c - hellomake.c - makefile - obj/- include/ - hellomake.h
// hellomake.h void myPrintHelloMake(void); // hellomake.c #includeint main(int argc, char** argv) { myPrintHelloMake(); return 0; } // hellofunc.c #include #include void myPrintHelloMake(void) { printf("Hello makefiles!\n"); return ; }
# makefileIDIR =../includeCC=gccCFLAGS=-I$(IDIR)ODIR=objLDIR =../libLIBS=-lm_DEPS = hellomake.hDEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))_OBJ = hellomake.o hellofunc.o OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))$(ODIR)/%.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS)hellomake: $(OBJ) gcc -o $@ $^ $(CFLAGS) $(LIBS).PHONY: cleanclean: rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~
From: