185 lines
7.5 KiB
Makefile
185 lines
7.5 KiB
Makefile
# The MIT License (MIT)
|
|
#
|
|
# Copyright (C) 2026 Scott Duensing
|
|
#
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
# of this software and associated documentation files (the "Software"), to
|
|
# deal in the Software without restriction, including without limitation the
|
|
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
# sell copies of the Software, and to permit persons to whom the Software is
|
|
# furnished to do so, subject to the following conditions:
|
|
#
|
|
# The above copyright notice and this permission notice shall be included in
|
|
# all copies or substantial portions of the Software.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
# IN THE SOFTWARE.
|
|
|
|
# DVX Shell Applications Makefile -- builds DXE3 modules
|
|
#
|
|
# Source tree is now one dir per app, mirroring bin/apps/kpunch/.
|
|
|
|
include ../../common.mk
|
|
|
|
APP_INCLUDES = -I../../libs/kpunch -I../../libs/kpunch/libdvx -I../../libs/kpunch/libdvx/platform -I../../libs/kpunch/libdvx/thirdparty -I../../widgets/kpunch -I../../libs/kpunch/libtasks -I../../libs/kpunch/dvxshell
|
|
CFLAGS = $(DOS_CFLAGS) $(APP_INCLUDES)
|
|
|
|
OBJDIR = ../../../obj/apps
|
|
BINROOT = ../../../bin
|
|
BINDIR = $(BINROOT)/apps
|
|
DVXRES = ../../../bin/host/dvxres
|
|
|
|
# C apps are discovered, never listed: every directory <app>/ holding
|
|
# <app>/<app>.c is one app. All .c files in that directory are linked into
|
|
# bin/apps/kpunch/<app>/<app>.app, and <app>/<app>.res (when present) is
|
|
# appended by dvxres with every .bmp in the directory as a dependency.
|
|
C_APP_MAINS = $(wildcard */*.c)
|
|
C_APPS = $(sort $(foreach f,$(C_APP_MAINS),$(if $(filter $(notdir $(basename $(f))),$(patsubst %/,%,$(dir $(f)))),$(patsubst %/,%,$(dir $(f))))))
|
|
|
|
BASCOMP = ../../../bin/host/bascomp
|
|
# BASIC apps: each is a .dbp project in its own directory.
|
|
# BASIC-only notepad, imgview, etc. replace the old C versions.
|
|
BASIC_APPS = iconed notepad imgview helpedit resedit basdemo widshow
|
|
|
|
.PHONY: all clean $(C_APPS) dvxbasic $(BASIC_APPS)
|
|
|
|
all: $(C_APPS) dvxbasic $(BASIC_APPS)
|
|
|
|
dvxbasic:
|
|
$(MAKE) -C dvxbasic
|
|
|
|
# bascomp is produced by the dvxbasic sub-make; this rule gives the BASIC app
|
|
# rules a real target to depend on so parallel builds order correctly.
|
|
$(BASCOMP): | dvxbasic
|
|
@:
|
|
|
|
# Per-app sources, objects and resource inputs.
|
|
appSrcs = $(wildcard $(1)/*.c)
|
|
appObjs = $(patsubst $(1)/%.c,$(OBJDIR)/$(1)/%.o,$(call appSrcs,$(1)))
|
|
appRes = $(wildcard $(1)/$(1).res)
|
|
appDeps = $(call appRes,$(1)) $(if $(call appRes,$(1)),$(wildcard $(1)/*.bmp))
|
|
|
|
# $(1) = app directory name. $(2) = extra shell commands run after linking
|
|
# (empty for most apps).
|
|
define C_APP_RULES
|
|
$(1): $(BINDIR)/kpunch/$(1)/$(1).app
|
|
|
|
$(BINDIR)/kpunch/$(1)/$(1).app: $(call appObjs,$(1)) $(call appDeps,$(1))
|
|
@mkdir -p $$(dir $$@)
|
|
$$(DXE3GEN) -o $$@ -U $(call appObjs,$(1))
|
|
$(if $(call appRes,$(1)),cd $(1) && ../$$(DVXRES) build ../$$@ $(1).res)
|
|
$(2)
|
|
|
|
$(OBJDIR)/$(1)/%.o: $(1)/%.c $$(DVX_MAKEFILES)
|
|
@mkdir -p $$(dir $$@)
|
|
$$(CC) $$(CFLAGS) -c -o $$@ $$<
|
|
endef
|
|
|
|
DVXDEMO_BMPS = logo.bmp new.bmp open.bmp sample.bmp save.bmp
|
|
DVXDEMO_POST = cp $(addprefix dvxdemo/,$(DVXDEMO_BMPS)) $(BINDIR)/kpunch/dvxdemo/
|
|
|
|
$(foreach a,$(C_APPS),$(eval $(call C_APP_RULES,$(a),$(if $(filter dvxdemo,$(a)),$(DVXDEMO_POST)))))
|
|
|
|
C_APP_OBJS = $(foreach a,$(C_APPS),$(call appObjs,$(a)))
|
|
|
|
# BASIC apps (compiled from .dbp projects via bascomp). Source for each app
|
|
# is under the app's own directory.
|
|
#
|
|
# F1 needs no resource: the shell presets an app's help file to <name>.hlp
|
|
# beside the .app (compiled there from <dir>/<name>.dhs by compile-help).
|
|
|
|
iconed: $(BINDIR)/kpunch/iconed/iconed.app
|
|
|
|
$(BINDIR)/kpunch/iconed/iconed.app: iconed/iconed.dbp iconed/iconed.frm iconed/ICON32.BMP $(BASCOMP) | $(BINDIR)/kpunch/iconed dvxbasic
|
|
$(BASCOMP) iconed/iconed.dbp -o $@ -release
|
|
|
|
notepad: $(BINDIR)/kpunch/notepad/notepad.app
|
|
|
|
$(BINDIR)/kpunch/notepad/notepad.app: notepad/notepad.dbp notepad/notepad.frm notepad/ICON32.BMP $(BASCOMP) | $(BINDIR)/kpunch/notepad dvxbasic
|
|
$(BASCOMP) notepad/notepad.dbp -o $@ -release
|
|
|
|
imgview: $(BINDIR)/kpunch/imgview/imgview.app
|
|
|
|
$(BINDIR)/kpunch/imgview/imgview.app: imgview/imgview.dbp imgview/imgview.frm imgview/ICON32.BMP $(BASCOMP) | $(BINDIR)/kpunch/imgview dvxbasic
|
|
$(BASCOMP) imgview/imgview.dbp -o $@ -release
|
|
|
|
helpedit: $(BINDIR)/kpunch/dvxhelp/helpedit.app
|
|
|
|
$(BINDIR)/kpunch/dvxhelp/helpedit.app: dvxhelp/helpedit/helpedit.dbp dvxhelp/helpedit/helpedit.frm dvxhelp/helpedit/ICON32.BMP $(BASCOMP) | $(BINDIR)/kpunch/dvxhelp dvxbasic
|
|
$(BASCOMP) dvxhelp/helpedit/helpedit.dbp -o $@ -release
|
|
|
|
resedit: $(BINDIR)/kpunch/resedit/resedit.app
|
|
|
|
$(BINDIR)/kpunch/resedit/resedit.app: resedit/resedit.dbp resedit/resedit.frm resedit/ICON32.BMP $(BASCOMP) | $(BINDIR)/kpunch/resedit dvxbasic
|
|
$(BASCOMP) resedit/resedit.dbp -o $@ -release
|
|
|
|
basdemo: $(BINDIR)/kpunch/basdemo/basdemo.app
|
|
|
|
$(BINDIR)/kpunch/basdemo/basdemo.app: basdemo/basdemo.dbp basdemo/basdemo.frm basdemo/shape.cls basdemo/ICON32.BMP $(BASCOMP) | $(BINDIR)/kpunch/basdemo dvxbasic
|
|
$(BASCOMP) basdemo/basdemo.dbp -o $@ -release
|
|
|
|
widshow: $(BINDIR)/kpunch/widshow/widshow.app
|
|
|
|
$(BINDIR)/kpunch/widshow/widshow.app: widshow/widshow.dbp widshow/widshow.frm widshow/ICON32.BMP $(BASCOMP) | $(BINDIR)/kpunch/widshow dvxbasic
|
|
$(BASCOMP) widshow/widshow.dbp -o $@ -release
|
|
|
|
# Native host build (test harness): each C app becomes a plain ELF shared
|
|
# object under obj/host/apps/<name>.so with its resources appended by
|
|
# dvxres exactly as on DOS (the resource footer trails the ELF image, which
|
|
# the dynamic loader ignores). SAN/COV per common.mk.
|
|
HOSTOBJDIR = $(HOST_OBJROOT)/apps
|
|
HOSTCFLAGS = $(HOST_CFLAGS) $(APP_INCLUDES)
|
|
HOSTLDFLAGS = -shared $(HOST_LDFLAGS) $(HOST_APP_LDFLAGS)
|
|
HOST_SOS = $(foreach n,$(C_APPS),$(HOSTOBJDIR)/$(n).so)
|
|
|
|
appHostObjs = $(patsubst $(1)/%.c,$(HOSTOBJDIR)/$(1)/%.o,$(call appSrcs,$(1)))
|
|
|
|
# $(1) = app directory name.
|
|
define C_APP_HOST_RULES
|
|
$(HOSTOBJDIR)/$(1).so: $(call appHostObjs,$(1)) $(call appDeps,$(1))
|
|
$$(HOSTCC) $$(HOSTLDFLAGS) -o $$@ $(call appHostObjs,$(1))
|
|
$(if $(call appRes,$(1)),cd $(1) && ../$$(DVXRES) build ../$$@ $(1).res)
|
|
|
|
$(HOSTOBJDIR)/$(1)/%.o: $(1)/%.c $$(DVX_MAKEFILES)
|
|
@mkdir -p $$(dir $$@)
|
|
$$(HOSTCC) $$(HOSTCFLAGS) -c -o $$@ $$<
|
|
endef
|
|
|
|
$(foreach a,$(C_APPS),$(eval $(call C_APP_HOST_RULES,$(a))))
|
|
|
|
HOST_APP_OBJS = $(foreach a,$(C_APPS),$(call appHostObjs,$(a)))
|
|
|
|
.PHONY: host host-clean
|
|
|
|
host: $(HOST_SOS)
|
|
|
|
host-clean:
|
|
rm -rf $(HOSTOBJDIR)
|
|
|
|
$(BINDIR)/kpunch/dvxhelp: ; mkdir -p $@
|
|
$(BINDIR)/kpunch/iconed: ; mkdir -p $@
|
|
$(BINDIR)/kpunch/notepad: ; mkdir -p $@
|
|
$(BINDIR)/kpunch/imgview: ; mkdir -p $@
|
|
$(BINDIR)/kpunch/resedit: ; mkdir -p $@
|
|
$(BINDIR)/kpunch/basdemo: ; mkdir -p $@
|
|
$(BINDIR)/kpunch/widshow: ; mkdir -p $@
|
|
|
|
-include $(C_APP_OBJS:.o=.d) $(HOST_APP_OBJS:.o=.d)
|
|
|
|
clean:
|
|
rm -f $(C_APP_OBJS) $(C_APP_OBJS:.o=.d)
|
|
rm -f $(foreach a,$(C_APPS),$(BINDIR)/kpunch/$(a)/$(a).app)
|
|
rm -f $(addprefix $(BINDIR)/kpunch/dvxdemo/,$(DVXDEMO_BMPS))
|
|
rm -f $(BINDIR)/kpunch/iconed/iconed.app
|
|
rm -f $(BINDIR)/kpunch/notepad/notepad.app
|
|
rm -f $(BINDIR)/kpunch/imgview/imgview.app
|
|
rm -f $(BINDIR)/kpunch/dvxhelp/helpedit.app
|
|
rm -f $(BINDIR)/kpunch/resedit/resedit.app
|
|
rm -f $(BINDIR)/kpunch/basdemo/basdemo.app
|
|
rm -f $(BINDIR)/kpunch/widshow/widshow.app
|
|
$(MAKE) -C dvxbasic clean
|