I'm trying to define specific lines of code to be run using a makefile like so
all: my_prog
my_prog: main.o count.o median.o maximum.o
gcc main.o count.o median.o maximum.i -o my_prog
main.o: main.c count.h median.h maximum.h
gcc count.c -c
median: median.c median.h
gcc -g -DMEDIAN median.c count.o main.o -o median
maximum: maximum.c maximum.h
gcc -g -DMAXIMUM maximum.c count.o main.o -o maximum
clean:
rm -f *.o my_prog median maximum
I'm trying to make the median and maximum files in my main function dependent on whether the user wants to use them or not and in my main.c the functions are defined
#ifdef MAXIMUM
long max = maximum(arr, size);
printf("The maximum is %Ld. \n", max);
#endif
#ifdef MEDIAN
long med = median(arr, size);
printf("The median is %Ld. \n", med);
#endif
The rest of my code works fine but when I try to run the executables it acts like these lines of code aren't even here.