Cross Compile Cups Ghostscript gstoraster Embedded Print

From richud.com
Jump to navigation Jump to search

The object of this is to be able to print labels on a DYMO LabelWriter 450 from an embedded system.

I put this together as a lot of the docs and info around it are, at best, confusing / outdated / wrong, or all three.

I am showing it as chunks of a custom system's Makefile as it will probably be what you are trying to do and hopefully make it clearer too.

CUPS

CUPS by default will compile genstrings and mantohtml using the cross compiler, then try and run them locally as part of the rest of the build process, hence failing. The easiest solution is to ignore these bits by just building the rest of cups without them, forgetting localisations and manual crap.

(If you want to do it the hard way, compile it with local compiler. Copy genstrings and mantohtml out. make distclean , start again with cross compiler. When it errors copy the file back in it errors on , make again, then it will stick on next one, copy that back in too, make again and it should complete. Or something like that. I wouldn't bother though.)

Gotchas;

  • Note libdir needs specifying otherwise it uses /lib64 for some reason.
  • Note it uses DSTROOT not DESTDIR.
  • Note it selectively ignores LDFLAGS so you need to put path on the --with-optim= parameter to get it through. (for ld linker to libz, -lz)

This (below) creates the needed bits without requiring genstrings or mantohtml, note you will see a genstrings error but it won't cause a problem as you are doing each bit separately.

This is as minimal as I think you can get it.

cups :
	cd "$(SOURCE)/$(cups_PATH)" ;\
	LDFLAGS="-L$(SOURCE)/$(zlib_PATH) -lz" \
	CPPFLAGS="-I$(SOURCE)/$(zlib_PATH)" \
	./configure --host=$(HOST) --prefix= --enable-shared --with-optim="-L$(SOURCE)/$(zlib_PATH)" --with-system-groups=root \
	--disable-dbus --disable-gssapi --disable-ssl --disable-pam --disable-avahi --disable-dnssd --disable-launchd --disable-browsing --disable-webif \
	--without-java --without-perl --without-php --without-python \
	--libdir=/lib ;\
	make -j4 -C cups ;\
	make -j4 -C filter ;\
	make -j4 -C backend ;\
	make -j4 -C ppdc ;\
	make -j4 -C scheduler ;\
	make -j4 -C systemv ;\
	make -j4 -C conf ;\
	make -C cups DSTROOT=$(DESTDIR) install ;\
	make -C filter DSTROOT=$(DESTDIR) install ;\
	make -C backend DSTROOT=$(DESTDIR) install ;\
	make -C ppdc DSTROOT=$(DESTDIR) install ;\
	make -C scheduler DSTROOT=$(DESTDIR) install ;\
	make -C systemv DSTROOT=$(DESTDIR) install ;\
	make -C conf DSTROOT=$(DESTDIR) install

DYMO LabelWriter 450 PPD Driver

This builds the ppd (driver) and the filters for cups.

  • Note ac_cv_path_cupsc= breaks it automatically finding the wrong paths by using local cups-config, allowing overriding with cups_datadir and cups_serverbindir
dymo-cups-drivers:
	cd "$(SOURCE)/$(dymocupsdrivers_PATH)" ;\
	LIBS="-L$(SOURCE)/$(zlib_PATH) -lz -L$(SOURCE)/$(cups_PATH)/cups -L$(SOURCE)/$(cups_PATH)/filter" \
	CPPFLAGS="-I$(SOURCE)/$(zlib_PATH) -I$(SOURCE)/$(cups_PATH)/" \
	cups_datadir=/share/cups cups_serverbindir=/lib/cups \
	./configure --host=$(HOST) ac_cv_path_cupsc= && make -j4 && make DESTDIR=$(DESTDIR) install ;\

Ghostscript genarch

  1. this will crap out, but ok, then copy genarch binary to eventual target machine and run it to generate an arch-xxx.h which you need back for making ghostscript proper
  2. run "genarch arch-myarch.h" on target
ghostarch:
	cd "$(SOURCE)/$(ghostscript_PATH)" ;\
	make distclean ;\
	LDFLAGS="-L$(SOURCE)/$(zlib_PATH) -lz -L$(SOURCE)/$(cups_PATH)/cups -lcups -L$(SOURCE)/$(cups_PATH)/filter -lcupsimage" \
	CPPFLAGS="-I$(SOURCE)/$(zlib_PATH) -I$(SOURCE)/$(cups_PATH)" \
	CFLAGS="-DHAVE_STDINT_H -D_GNU_SOURCE -O3" \
	./configure  ac_cv_path_CUPSCONFIG="$(SOURCE)/$(cups_PATH)/cups-config" --host=$(HOST) \
	--prefix= --disable-fontconfig --disable-contrib --disable-dbus --disable-openjpeg  --disable-gtk --enable-little-endian \
	--without-jbig2dec --without-ijs --without-libpaper --without-luratech  --without-ijs --without-libidn --without-x --without-omni \
	--with-libiconv=no --with-system-libtiff --with-pdftoraster --with-drivers=FILES ;\
	make obj/arch.h


Ghostscript Proper

ghostscript:
	cd "$(SOURCE)/$(ghostscript_PATH)" ;\
	make distclean ;\
	LDFLAGS="-L$(SOURCE)/$(zlib_PATH) -lz -L$(SOURCE)/$(cups_PATH)/cups -lcups -L$(SOURCE)/$(cups_PATH)/filter -lcupsimage" \
	CPPFLAGS="-I$(SOURCE)/$(zlib_PATH) -I$(SOURCE)/$(cups_PATH)" \
	CFLAGS="-DHAVE_STDINT_H -D_GNU_SOURCE -O3" \
	./configure  ac_cv_path_CUPSCONFIG="$(SOURCE)/$(cups_PATH)/cups-config" --host=$(HOST) \
	--prefix= --disable-fontconfig --disable-contrib --disable-dbus --disable-openjpeg  --disable-gtk --enable-little-endian \
	--without-jbig2dec --without-ijs --without-libpaper --without-luratech  --without-ijs --without-libidn --without-x --without-omni \
	--with-libiconv=no --with-system-libtiff --with-pdftoraster --with-drivers=FILES ;\
	make -j4 CCAUX=gcc TARGET_ARCH_FILE="$(CUST)/arch-i386.h" && make -j4 DESTDIR=$(DESTDIR) install

gstoraster PS or PDF to raster

gstoraster:
	cd "$(SOURCE)/$(gstoraster_PATH)" ;\
	make CUPSCONFIG="$(SOURCE)/$(cups_PATH)/cups-config" \
	LDFLAGS="-L$(SOURCE)/$(zlib_PATH) -lz -L$(SOURCE)/$(cups_PATH)/cups -lcups -L$(SOURCE)/$(cups_PATH)/filter -lcupsimage" \
	CPPFLAGS="-I$(SOURCE)/$(zlib_PATH) -I$(SOURCE)/$(cups_PATH)" \
	&& make CUPSCONFIG="$(SOURCE)/$(cups_PATH)/cups-config" DESTDIR=$(DESTDIR) install