#!/usr/bin/perl use strict; use warnings; my $header; my @syms; open FILE, "<", "/usr/include/libdrm/drm_fourcc.h" or die "open drm_fourcc.h: $!"; { local $/; undef $/; $header = ; } close FILE; $header =~ s/\\\n//g; foreach my $line (split /\n/, $header) { next unless $line =~ m/#define\s+([a-zA-Z0-9_]+)\s+fourcc_mod_code/; push @syms, $1; } open FILE, ">", "drmfmtmods.h" or die "open drmfmtmods.h: $!"; print FILE "/* generated by update-fmtmod.pl */\n"; for my $sym (@syms) { my $name = $sym; $name =~ s/^DRM_FORMAT_MOD_//; printf FILE "{ .mod = %s, .name = \"%s\" },\n", $sym, $name; } close FILE;