I don't want to use -I
flags each time for including a header file I made before. I want to specify a directory and save header files there and make GNU gcc search there by default.
PS: I use windows and GNU 5.1.0.
I don't want to use -I
flags each time for including a header file I made before. I want to specify a directory and save header files there and make GNU gcc search there by default.
PS: I use windows and GNU 5.1.0.
because of my low reputation I couldn't add comment, I think you can use your own make file learning from this link:
http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
or this:
https://www.cs.oberlin.edu/~kuperman/help/make.html
or write your own script.
If all your header files are stored in the same directory, you need not include each .h file using -I option. You can do something like
$(GCC) $(CFLAGS) -I$(HDR_INC_PATH) -c <source files>
where HDR_INC_PATH contains the path where your headers are stored.
If you have headers located in multiple locations, you can do something like
HDR_INC_PATH := -I<path1> \
-I<path2> \
-I<path3> \
and so on
where path1, path2 and path3 are the locations where the headers are located and use
$(GCC) $(CFLAGS) $(HDR_INC_PATH) -c <source files>
You can also make use of $(wildcard pattern) to search for all the header files in a directory. In this case you have to mention the top directory path so that headers in child directories are also taken. Something like
HDR_FILES = $(wildcard <dir>/*.h)
where dir is the path of your parent directory. You can then make use $(HDR_FILES) with -I in your compiler recipe.