Include headers as dependencies

This commit is contained in:
K. Lange 2018-04-17 22:30:19 +09:00 committed by Kevin Lange
parent c0853fa5ce
commit e753f83c48

View File

@ -12,6 +12,10 @@ except KeyError:
force_static = [] force_static = []
special_headers = {
'-ltoaru_dlfcn': 'base/usr/include/dlfcn.h',
}
class Classifier(object): class Classifier(object):
dependency_hints = { dependency_hints = {
@ -93,6 +97,12 @@ def todep(name):
else: else:
return (False, name) return (False, name)
def toheader(name):
if name in special_headers:
return special_headers[name]
if name.startswith('-ltoaru_'):
return name.replace('-ltoaru_','base/usr/include/toaru/') + '.h'
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) < 3: if len(sys.argv) < 3:
print("usage: util/auto-dep.py command filename") print("usage: util/auto-dep.py command filename")
@ -112,17 +122,19 @@ if __name__ == "__main__":
order_only = [x[1] for x in results if x[0]] order_only = [x[1] for x in results if x[0]]
print(" ".join(normal) + " | " + " ".join(order_only)) print(" ".join(normal) + " | " + " ".join(order_only))
elif command == "--make": elif command == "--make":
print("base/bin/{app}: {source} | {libraryfiles} $(LC)\n\t$(CC) $(CFLAGS) -o $@ $< {libraries}".format( print("base/bin/{app}: {source} {headers} | {libraryfiles} $(LC)\n\t$(CC) $(CFLAGS) -o $@ $< {libraries}".format(
app=os.path.basename(filename).replace(".c",""), app=os.path.basename(filename).replace(".c",""),
source=filename, source=filename,
headers=" ".join([toheader(x) for x in c.libs]),
libraryfiles=" ".join([todep(x)[1] for x in c.libs]), libraryfiles=" ".join([todep(x)[1] for x in c.libs]),
libraries=" ".join([x for x in c.libs]))) libraries=" ".join([x for x in c.libs])))
elif command == "--makelib": elif command == "--makelib":
libname = os.path.basename(filename).replace(".c","") libname = os.path.basename(filename).replace(".c","")
_libs = [x for x in c.libs if not x.startswith('-ltoaru_') or x.replace("-ltoaru_","") != libname] _libs = [x for x in c.libs if not x.startswith('-ltoaru_') or x.replace("-ltoaru_","") != libname]
print("base/lib/libtoaru_{lib}.so: {source} | {libraryfiles} $(LC)\n\t$(CC) $(CFLAGS) -shared -fPIC -o $@ $< {libraries}".format( print("base/lib/libtoaru_{lib}.so: {source} {headers} | {libraryfiles} $(LC)\n\t$(CC) $(CFLAGS) -shared -fPIC -o $@ $< {libraries}".format(
lib=libname, lib=libname,
source=filename, source=filename,
headers=" ".join([toheader(x) for x in c.libs]),
libraryfiles=" ".join([todep(x)[1] for x in _libs]), libraryfiles=" ".join([todep(x)[1] for x in _libs]),
libraries=" ".join([x for x in _libs]))) libraries=" ".join([x for x in _libs])))